// const targetElement = document.querySelector('#wrapper > div.wrapper__holder > main'); // 替换为目标元素的选择器
//////////////////////////////////////////////////////////////// 添加秒表 start ////////////////////////////////////////////////////////////////
// if (targetElement) {
   // 创建秒表容器
   const stopwatchContainer = document.createElement('div');
   stopwatchContainer.id = 'stopwatch-container';
   stopwatchContainer.style.position = 'fixed';
   stopwatchContainer.style.top = '10px';
   stopwatchContainer.style.right = '10px';
   stopwatchContainer.style.zIndex = '9999';

   // 创建秒表
   const stopwatch = document.createElement('div');
   stopwatch.id = 'stopwatch';
   stopwatch.textContent = '00:00:00';
   stopwatch.style.fontSize = '2em';
   stopwatch.addEventListener('click', startTimer);
   stopwatchContainer.appendChild(stopwatch);

//    // 创建开始按钮
//    const startButton = document.createElement('button');
//    startButton.textContent = 'Start';
//    startButton.style.fontSize = '1em';
// //    startButton.style.padding = '10px 20px';
// //    startButton.style.margin = '10px';
//    startButton.addEventListener('click', startTimer);
//    stopwatchContainer.appendChild(startButton);

//    // 创建停止按钮
//    const stopButton = document.createElement('button');
//    stopButton.textContent = 'Stop';
//    stopButton.style.fontSize = '1em';
//    stopButton.style.padding = '10px 20px';
//    stopButton.style.margin = '10px';
//    stopButton.addEventListener('click', stopTimer);
//    stopwatchContainer.appendChild(stopButton);

//    // 创建重置按钮
//    const resetButton = document.createElement('button');
//    resetButton.textContent = 'Reset';
//    resetButton.style.fontSize = '1em';
//    resetButton.style.padding = '10px 20px';
//    resetButton.style.margin = '10px';
//    resetButton.addEventListener('click', resetTimer);
//    stopwatchContainer.appendChild(resetButton);

   // 将秒表容器添加到页面上
   document.body.appendChild(stopwatchContainer);

   let seconds = 0;
   let timer;
   let flag='start';
   function startTimer() {
       if (!timer && flag=='start') {
           flag='stop';
           timer = setInterval(() => {
               seconds++;
               document.getElementById('stopwatch').textContent = formatTime(seconds);
           }, 1000);
       }else{
        stopTimer();
        seconds = 0;
        document.getElementById('stopwatch').textContent = formatTime(seconds);
        flag='start';
       }
   }

   function stopTimer() {
       if (timer) {
           clearInterval(timer);
           timer = null;
       }
   }

   function resetTimer() {
       stopTimer();
       seconds = 0;
       document.getElementById('stopwatch').textContent = formatTime(seconds);
   }

   function formatTime(totalSeconds) {
       let hours = Math.floor(totalSeconds / 3600);
       let minutes = Math.floor((totalSeconds - (hours * 3600)) / 60);
       let secs = totalSeconds - (hours * 3600) - (minutes * 60);

       hours = hours < 10 ? '0' + hours : hours;
       minutes = minutes < 10 ? '0' + minutes : minutes;
       secs = secs < 10 ? '0' + secs : secs;

       return `${hours}:${minutes}:${secs}`;
   }
// }
//  });
